// 引入defineStore
import {defineStore} from 'pinia'
// 引入API
import { reqHospitalDetail, reqHospitalDeparment } from '@/api/hospital/index'
// 引入ts类型
import { HospitalDetailResponseDate, DepartmentResponseData } from '@/api/hospital/type'

// 创建一个医院详情仓库
const useDetailStore = defineStore('detailStore',{
    state:():any=>{
        return{
            // 存储一个医院的数据
            hospitalInfo:{},
            // 存储一个医院科室的数据
            departmentArr:[]
        }
    },
    actions:{
        // 获取一个医院详情的方法
        async getHospitalDetail(hoscode:string){
            let result:HospitalDetailResponseDate = await reqHospitalDetail(hoscode)
            if(result.code == 200 ){
                this.hospitalInfo = result.data
            }
        },
        // 获取一个医院科室数据的方法
        async getDepartment(hoscode: string){
            let result: DepartmentResponseData = await reqHospitalDeparment(hoscode)
            if (result.code == 200) {
                this.departmentArr = result.data
            }
        }
    },
    getters:{

    }
})

// 对外暴露医院详情仓库
export default useDetailStore;